Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: trigger sizes

  1. #11

    Default

    James, that is what I was trying to do I didn't know you can use that if statement more than 1 time, the 1st code you posted s how I have it now, the 2nd code is what I want to do, this way I don't have to change the map scr.
    so as long as you put the { } brackets in between you could keep adding cvar if, while, switch etc. statements ?

    also just so the people who answer my posts know I copy and paste everything to note pad and save them in case I may need it some day. I'm learning a lot , I get confused when I need to string stuff together. I went here
    http://www.gronnevik.se/rjukan/ printed out all the stuff thing was 2 inch's thick....lol but it doesn't really make sense to me.

  2. #12
    Administrator James's Avatar
    Join Date
    May 2010
    Location
    on the intraweb
    Posts
    3,071

    Default

    Yes, I believe I made a comment about how to use brackets with if and else statements... basically here is the rule of thumb..

    If you have one single line of code you're executing after a comparative statement (if or else) then you don't need brackets.
    If you have multiple lines of code that you're executing after a comparative statement, use brackets so all code is executed properly.

    HOWEVER... as a good practice, I use brackets all the time regardless of how many lines I execute afte a comparative statement.

    Does that make sense?
    Also to answer your question, you can use as many comparactive statements (under each other) as you want.

    Here is an example
    Code:
    if(something)
    {
        if(something)
        {
            if(something)
            {
                blah
            }
            else
            {
                blah2
            }
        }
    }
    else
    {
        if(something)
        {
            blah
        }
        else
        {
            if(something)
            {
                blah
            }
            else
            {
                blah2
            }
        }
    }
    Is that clear?

    I think it's great that you're trying to learn. It's all about trial and error. Just keep at it man. Wait till you get to 2 and 3 dimensional arrays.. or worse... vectors. haha.

    EDIT:
    After taking a second look at your code, you can narrow it down even further..
    Code:
    if((getcvar("mapname") == "obj/obj_team2") && (getcvar("punish") == "1"))
    { 
    		thread axis
    } 
    end

  3. #13

    Default

    Ok yeah that makes sense. so the && is what lets you add more cvar checks. just remember to put them in ( )

    if((getcvar("mapname") == "obj/obj_team2") && (getcvar("punish") == "1") && (getcvar (whatever) == 1) )

    cool now I'm really going to play around...lol

  4. #14
    Administrator James's Avatar
    Join Date
    May 2010
    Location
    on the intraweb
    Posts
    3,071

    Default

    Correct.. You have to understand the logic behind it though..

    && = and (so you're comparing 2 or more things)... and they both have to be true for it to continue to execute the code. If 1 doesn't meet the comparitave result, then the code in the brackets will never be executed.
    || = or so you're making a comparison with 2 or more things (much like above), but as long as 1 of the comparisons is true then the code gets executed. So if you have something like this...
    Code:
    if(cat == animal || dog == plant) //this is true and will continue because cat = animal even though dog doesn't equal plant
    
    if(cat == animal && dog == plant) //this won't get executed because both statements have to be true, and a dog isn't a plant...
    
    It can even get more complex for example this...
    
    if(((cat == animal || dog == plant) &&( (one == number) && (James == person) ) || (RazorRapid == prodigy))
    ^ Try to wrap your head around that one... haha.
    to make it easier break it up...

    if cat is an animal or a dog is a plant - this is true because cat is an animal
    AND
    one is a number and James is a person - (you're comparing two things here with the AND operand, so both have to be true.. and it is true.. Unless I'm an alien) lol
    OR
    RazorRapid is a prodigy - we all know this is true. However if the previous comparison failed, then the if statement would still pass because I'm checking if RazorRapid is a prodigy, which he is, so it would supersede the previous comparitave statement..


    So... The final result would mean since all statements passed any code in the bracket would be executed.. Make sense?

  5. #15

    Default

    yes it does for me that's strange but I get it...lol.

  6. #16

    Default Thanks Everyone

    Ok wanted to say Thank You to everyone who helped educate me on scripting. THANK YOU It all works great the axis part is turned on or off in console, and the allied part stays on all the time. I even figured out how to make the trigger reset at the end of the round ( may not be the best way but it gets the job done). Mod works great.

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •